package com.wenx.jvm;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

public class OOMDemo1 {

    private List<Object> list = new ArrayList<>();

    private Integer i = 0;

    public static void main(String[] args) throws InterruptedException {

        TimeUnit.SECONDS.sleep(10L);

        new OOMDemo1().prints();

    }

    private void prints() throws InterruptedException {
        TimeUnit.MILLISECONDS.sleep(10L);
        list.add(new Object());
        System.out.println(i++);
        prints();
    }

}
